<?php

namespace App\Http\Controllers\Admin;

use App\Article as ArticleModel;
use App\Replies as RepliesModel;

class Index extends Base
{
    public function main()
    {
        $appInfo = [
            'ip地址'    => request()->getClientIP(),
            '域名'      => request()->url(),
            'php版本'   => PHP_VERSION,
            'ZEND版本'  => zend_version(),
            'MYSQL支持' => function_exists('mysqli_close') ? '是' : '否',
            '服务器操作系统' => PHP_OS,
            '服务器端信息'  => request()->server('SERVER_SOFTWARE'),
            '最大上传限制'  => get_cfg_var('upload_max_filesize') ?: '不允许上传附件',
            '最大执行时间'  => get_cfg_var("max_execution_time") . '秒',
        ];

        // 查询今天的条件
        $map = [
            strtotime(date("Y-m-d"), time()),
            time(),
        ];
        // 查询今天的文章数
        $countInfo['今天']['article_count'] = ArticleModel::whereBetween('created_at', $map)->count();
        // 查询今天的回复数
        $countInfo['今天']['replies_count'] = RepliesModel::whereBetween('created_at', $map)->count();

        //查询所有的文章数
        $countInfo['到现在']['article_count'] = ArticleModel::count();
        //查询所有的回复数
        $countInfo['到现在']['replies_count'] = RepliesModel::count();

        return view('admin.index.index', [
            'appInfo'   => $appInfo,
            'countInfo' => $countInfo,
        ]);
    }
}
